home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / zm16src.lzh / YMODEM.DOC < prev    next >
Text File  |  1988-05-05  |  64KB  |  1,681 lines

  1.       
  2.       
  3.       
  4.                                   - 1 -
  5.       
  6.       
  7.       
  8.                      XMODEM/YMODEM PROTOCOL REFERENCE
  9.                  A compendium of documents describing the
  10.       
  11.                             XMODEM and YMODEM
  12.       
  13.                          File Transfer Protocols
  14.       
  15.       
  16.       
  17.       
  18.                    This document was formatted 9-11-86.
  19.       
  20.       
  21.       
  22.       
  23.       
  24.       
  25.       
  26.                          Edited by Chuck Forsberg
  27.       
  28.       
  29.       
  30.       
  31.       
  32.       
  33.       
  34.       
  35.       
  36.       
  37.       
  38.       
  39.       
  40.       
  41.                  Please distribute as widely as possible.
  42.       
  43.                        Questions to Chuck Forsberg
  44.       
  45.       
  46.       
  47.       
  48.       
  49.                            Omen Technology Inc
  50.                         17505-V Sauvie Island Road
  51.                           Portland Oregon 97231
  52.                            Voice: 503-621-3406
  53.             Modem (Telegodzilla): 503-621-3746 Speed 1200,300
  54.                           Compuserve: 70007,2304
  55.                     UUCP: ...!tektronix!reed!omen!caf
  56.       
  57.       
  58.       
  59.       
  60.       
  61.       
  62.       
  63.       
  64.       
  65.       
  66.       
  67.       
  68.       
  69.       
  70.                                   - 2 -
  71.       
  72.       
  73.       
  74.       1.  ROSETTA STONE
  75.       
  76.       Here are some definitions which reflect the current vernacular
  77.       in the computer media. The attempt here is identify the file
  78.       transfer protocol rather than specific programs.
  79.       
  80.       XMODEM refers to the original 1979 file transfer etiquette
  81.        introduced by Ward Christensen's 1979 MODEM2 program.  It's also
  82.        called the MODEM or MODEM2 protocol.  Some who are unaware of MODEM7's
  83.        unusual batch file mode call it MODEM7.  Other aliases include "CP/M
  84.        Users's Group" and "TERM II FTP 3".  This protocol is supported by
  85.        every serious communications program because of its universality,
  86.        simplicity, and reasonable performance.
  87.       
  88.       XMODEM/CRC replaces XMODEM's 1 byte checksum with a two byte Cyclical
  89.        Redundancy Check (CRC-16), giving modern error detection
  90.        protection.
  91.       
  92.       XMODEM-1k Refers to the XMODEM/CRC protocol with 1024 byte data blocks.
  93.       
  94.       YMODEM refers to the XMODEM/CRC (optional 1k blocks) protocol with the
  95.        batch transmission described below.
  96.       
  97.       ZMODEM uses familiar XMODEM/CRC and YMODEM technology in a
  98.        new protocol that provides reliability, throughput, file
  99.        management, and user amenities appropriate to contemporary
  100.        data communications. 
  101.       
  102.       
  103.       2.  YET ANOTHER PROTOCOL?
  104.       
  105.       Since its development half a decade ago, the Ward Christensen modem
  106.       protocol has enabled a wide variety of computer systems to interchange
  107.       data.  There is hardly a communications program that doesn't at least
  108.       claim to support this protocol.
  109.       
  110.       Recent advances in computing, modems and networking have
  111.       revealed a number of weaknesses in the original protocol:
  112.       
  113.          + The short block length caused throughput to suffer when used with
  114.            timesharing systems, packet switched networks, satellite circuits,
  115.            and buffered (error correcting) modems.
  116.       
  117.          + The 8 bit arithmetic checksum and other aspects allowed line
  118.            impairments to interfere with dependable, accurate transfers.
  119.       
  120.          + Only one file could be sent per command.  The file name had to be
  121.            given twice, first to the sending program and then again to the
  122.            receiving program.
  123.       
  124.          + The transmitted file could accumulate as many as 127 extraneous
  125.            bytes.
  126.       
  127.       
  128.       
  129.       Chapter 2  
  130.       
  131.       
  132.       
  133.       
  134.       
  135.       
  136.       X/YMODEM Protocol Reference        09-11-86                        3
  137.       
  138.       
  139.       
  140.          + The modification date of the file was lost.
  141.       
  142.       A number of other protocols have been developed over the
  143.       years, but none  have displaced XMODEM to date:
  144.       
  145.          + Lack of public domain documentation and example programs have kept
  146.            proprietary protocols such as MNP, Blast, and others
  147.            tightly bound to the fortunes of their suppliers. 
  148.       
  149.          + Complexity discourages the widespread application of BISYNC, SDLC,
  150.            HDLC, X.25, and X.PC protocols.
  151.       
  152.          + Performance compromises and moderate complexity have limited the
  153.            popularity of the Kermit protocol, which was developed to allow file
  154.            transfers in environments hostile to XMODEM.
  155.       
  156.       The XMODEM protocol extensions and YMODEM Batch address these
  157.       weaknesses while maintaining XMODEM's simplicity.
  158.       
  159.       YMODEM is supported by the public domain programs YAM (CP/M),
  160.       YAM(CP/M-86), YAM(CCPM-86), IMP (CP/M), KMD (CP/M), rz/sz (Unix, Xenix,
  161.       VMS, Berkeley Unix, Venix, Xenix, Coherent, IDRIS, Regulus).  Commerical
  162.       implementations include MIRROR, and Professional-YAM.[1] Communications
  163.       programs supporting these extensions have been in use since 1981.
  164.       
  165.       The 1k packet length (XMODEM-1k) described below may be used in
  166.       conjunction with YMODEM Batch Protocol, or with single file transfers
  167.       identical to the XMODEM/CRC protocol except for minimal
  168.        changes to support 1k packets.
  169.       
  170.       Another extension is simply called the g option.  It provides maximum
  171.       throughput when used with end to end error correcting media,
  172.       such as X.PC and error correcting modems, including the emerging
  173.       9600 bps units by Electronic Vaults and others.
  174.       
  175.       To complete this tome, Ward Christensen's original protocol document and
  176.       John Byrns's CRC-16 document are included for reference.
  177.       
  178.       References to the MODEM or MODEM7 protocol have been changed
  179.       to XMODEM to accommodate the vernacular. In Australia, it is
  180.       properly called the Christensen Protocol.
  181.       
  182.       
  183.       
  184.       
  185.       
  186.       
  187.       __________
  188.       
  189.        1. Available for IBM PC,XT,AT, Unix and Xenix
  190.       
  191.       
  192.       
  193.       
  194.       Chapter   2
  195.       
  196.       
  197.       
  198.       
  199.       
  200.       
  201.       
  202.       X/YMODEM Protocol Reference         09-11-86                      4
  203.       
  204.       
  205.       
  206.       2.1  Some Messages from the Pioneer
  207.       
  208.       #: 130940 S0/Communications 25-Apr-85  18:38:47
  209.       Sb: my protocol
  210.       Fm: Ward Christensen 76703,302 (EDITED)
  211.       To: all
  212.       
  213.       Be aware the article[2] DID quote me correctly in terms of the
  214.       phrases like "not robust", etc.
  215.       
  216.       It was a quick hack I threw together, very unplanned (like
  217.       everything I do), to satisfy a personal need to communicate with
  218.       "some other" people. 
  219.       
  220.       ONLY the fact that it was done in 8/77, and that I put it in the public
  221.       domain immediately, made it become the standard that it is.
  222.       
  223.       I think its time for me to
  224.       
  225.       (1) document it; (people call me and say "my product is going
  226.           to include  it - what can I 'reference'", or "I'm writing a
  227.           paper on it, what do I put in the bibliography") and
  228.       
  229.       (2) propose an "incremental extension" to it, which might take
  230.           "exactly" the form of Chuck Forsberg's YAM protocol.  He
  231.            wrote YAM in C for CP/M and  put it in the public domain,
  232.            and wrote a batch protocol for Unix[3] called rb and sb
  233.            (receive batch, send batch), which was basically XMODEM with 
  234.           (a) a record 0 containing filename date time and size
  235.           (b) a 1K block size option
  236.           (c) CRC-16.
  237.       
  238.       He did some clever programming to detect false ACK or EOT, but basically
  239.       left them the same.
  240.       
  241.       People who suggest I make SIGNIFICANT changes to the protocol,
  242.       such as "full duplex", "multiple outstanding blocks", "multiple
  243.       destinations", etc etc don't understand that the incredible
  244.       simplicity of the protocol is one of the reasons it survived to
  245.       this day in as many machines and programs as it may be found in!
  246.       
  247.       Consider the PC-NET group back in '77 or so - documenting to
  248.       beat the band 
  249.       - THEY had a protocol, but it was "extremely complex", because
  250.         it tried to be "all things to all people" - i.e. send binary
  251.         files on a 7-bit system,  etc.  I was not that "benevolent". I
  252.         (emphasize > I < ) had an 8-bit UART,  
  253.       
  254.       
  255.       __________
  256.       
  257.        2. Infoworld April 29 p. 16
  258.       
  259.        3. VAX/VMS versions of these programs are also available.
  260.       
  261.       
  262.       
  263.       
  264.       Chapter   2
  265.       
  266.       
  267.       
  268.       
  269.       
  270.       
  271.       
  272.       X/YMODEM Protocol Reference        09-11-86                        5
  273.       
  274.       
  275.       
  276.       so "my protocol was an 8-bit protocol", and I would just say "sorry" to
  277.       people who were held back by 7-bit limitations.  ...
  278.       
  279.       Block size: Chuck Forsberg created an extension of my protocol,
  280.       called YAM, which is also supported via his public domain
  281.       programs for UNIX called rb and sb - receive batch and send
  282.       batch.  They cleverly send a "block 0" which contains the
  283.       filename, date, time, and size. Unfortunately, its UNIX style,
  284.       and is abit weird[4] - octal numbers, etc. BUT, it is a nice way
  285.       to overcome the kludgy "echo the chars of the name" introduced
  286.       with MODEM7. Further, chuck uses CRC-16 and optional 1K blocks.
  287.       Thus the record 0, 1K, and CRC, make it a "pretty slick new 
  288.       protocol" which is not significantly different from my own.
  289.       
  290.       Also, there is a catchy name - YMODEM. That means to some
  291.       that it is the  "next thing after XMODEM", and to others that it
  292.       is the Y(am)MODEM protocol.  I don't want to emphasize that too
  293.       much - out of fear that other mfgrs might think it is a
  294.       "competitive" protocol, rather than an "unaffiliated" protocol.
  295.       Chuck is currently selling a much-enhanced version of his
  296.       CP/M-80 C program YAM, calling it Professional Yam, and its 
  297.       for the PC - I'm using it right now.  VERY slick!  32K capture buffer,
  298.       script, scrolling, previously captured text search, plus
  299.       built-in commands for just about everything - directory (sorted
  300.       every which way), XMODEM, YMODEM, KERMIT, and ASCII file
  301.       upload/download, etc.  You can program it to "behave" with most
  302.       any system - for example when trying a number for CIS it detects
  303.       the "busy" string back from the modem and substitutes a diff
  304.       phone # into the dialing string and branches back to try it. 
  305.       
  306.       
  307.       
  308.       3.  XMODEM PROTOCOL ENHANCEMENTS
  309.       
  310.       This chapter discusses the protocol extensions to Ward Christensen's
  311.       1982 XMODEM protocol description document.
  312.       
  313.       The original document recommends the user be asked whether to continue
  314.       trying or abort after 10 retries.  Most programs no longer ask the
  315.       operator whether he wishes to keep retrying.  Virtually all correctable
  316.       errors are corrected within the first few retransmissions.  If
  317.       the line is so bad that ten attempts are insufficient, there is
  318.       a significant danger of undetected errors.  If the connection is
  319.       that bad, it's better to redial for a better connection, or
  320.       mail a floppy disk. 
  321.       
  322.       
  323.       
  324.       
  325.       
  326.       __________
  327.       
  328.        4. The file length, time, and file mode are optional.The pathname and
  329.           file length may be sent alone if desired.
  330.       
  331.       
  332.       
  333.       
  334.       Chapter   3                             XMODEM Protocol Enhancements
  335.       
  336.       
  337.       
  338.       
  339.       
  340.       
  341.       
  342.       X/YMODEM Protocol Reference        09-11-86                        6
  343.       
  344.       
  345.       
  346.       3.1  Graceful Abort
  347.       
  348.       The YAM and Professional-YAM X/YMODEM routines recognize a
  349.       sequence of two consecutive CAN (Hex 18) characters without modem
  350.       errors (overrun, framing, etc.) as a transfer abort command.  This
  351.       sequence is recognized when YAM is waiting for the beginning of a
  352.       packet or for an acknowledge to one that has been sent.  The
  353.       check for two consecutive CAN characters virtually eliminates the
  354.       possibility of a line hit aborting the transfer.  YAM sends
  355.       eight CAN characters when it aborts an XMODEM, YMODEM, or ZMODEM
  356.       protocol file transfer.  Pro-YAM then sends eight backspaces to delete
  357.       the CAN characters from the remote's keyboard input buffer, in
  358.       case the remote had already aborted the transfer and was
  359.       awaiting a keyboarded command.
  360.       
  361.       
  362.       3.2  CRC-16 Option
  363.       
  364.       The XMODEM protocol uses an optional two character CRC-16
  365.       instead of the one character arithmetic checksum used by the original
  366.       protocol and by most commercial implementations.  CRC-16
  367.       guarantees detection of all single and double bit errors, all errors
  368.       with an odd number of error bits, all burst errors of length 16 or
  369.       less, 99.9969% of all 17-bit error bursts, and 99.9984 per cent
  370.       of all possible longer error bursts.  By contrast, a double bit
  371.       error, or a burst error of 9 bits or more can sneak past the
  372.       XMODEM protocol arithmetic checksum.
  373.       
  374.       The XMODEM/CRC protocol is similar to the XMODEM protocol,
  375.       except that the receiver specifies CRC-16 by sending C (Hex
  376.       43) instead of NAK when requesting the FIRST packet.  A two
  377.       byte CRC is sent in place of the one byte arithmetic checksum.
  378.       
  379.       YAM's c option to the r command enables CRC-16 in single file
  380.       reception, corresponding to the original implementation in the
  381.       MODEM7 series programs.  This remains the default because many
  382.       commercial communications programs and bulletin board systems still do
  383.       not support CRC-16, especially those written in Basic or Pascal.
  384.       
  385.       XMODEM protocol with CRC is accurate provided both sender and
  386.       receiver both report a successful transmission. The protocol is robust
  387.       in the presence of characters lost by buffer overloading on
  388.       timesharing systems.
  389.       
  390.       The single character ACK/NAK responses generated by the
  391.       receiving program adapt well to split speed modems, where the reverse
  392.       channel is limited to ten per cent or less of he main channel's speed.
  393.       
  394.       XMODEM and YMODEM are half duplex protocols which do not attempt to
  395.       transmit information and control signals in both directions at the same
  396.       time.  This avoids buffer overrun problems that have been reported by
  397.       users attempting to exploit full duplex asynchronous file transfer
  398.       protocols such as Blast.
  399.       
  400.       Professional-YAM adds several proprietary logic enhancements to XMODEM's
  401.       
  402.       
  403.       
  404.       Chapter   3                                 XMODEM Protocol Enhancements
  405.       
  406.       
  407.       
  408.       
  409.       
  410.       
  411.       
  412.       X/YMODEM Protocol Reference        09-11-86                        7
  413.       
  414.       
  415.       
  416.       error detection and recovery.  These compatible enhancements eliminate
  417.       most of the bad file transfers other programs make when using
  418.       the XMODEM protocol under less than ideal conditions.
  419.       
  420.       
  421.       3.3  XMODEM-1k 1024 Byte Packet
  422.       
  423.       The choice to use 1024 byte packets is expressed to the sending
  424.       program on its command line or selection menu.[1] 1024 byte packets
  425.       improve throughput in many applications, but some environments cannot
  426.       accept 1024 byte bursts, especially minicomuters running 19.2kb
  427.       ports.
  428.       
  429.       An STX (02) replaces the SOH (01) at the beginning of the transmitted
  430.       block to notify the receiver of the longer packet length.  The
  431.       transmitted packet contains 1024 bytes of data.  The receiver
  432.       should be able to accept any mixture of 128 and 1024 byte
  433.       packets.  The packet number is incremented by one for each
  434.       packet regardless of the packet length. 
  435.       
  436.       The sender must not change between 128 and 1024 byte packet lengths if it
  437.       has not received a valid ACK for the current packet.  Failure to observe
  438.       this restriction allows certain transmission errors to pass undetected.
  439.       
  440.       If 1024 byte packets are being used, it is possible for a file to "grow"
  441.       up to the next multiple of 1024 bytes. This does not waste disk space if
  442.       the allocation granularity is 1k or greater.  With YMODEM batch
  443.       transmission, the optional file length transmitted in the file
  444.       name packet allows the receiver to discard the padding,
  445.       preserving the exact file length and contents.
  446.       
  447.       1024 byte packets may be used with batch file transmission or with single
  448.       file transmission.  CRC-16 should be used with the k option to preserve
  449.       data integrity over phone lines.  If a program wishes to enforce this
  450.       recommendation, it should cancel the transfer, then issue an informative
  451.       diagnostic message if the receiver requests checksum instead of CRC-16.
  452.       Under no circumstances may a sending program use CRC-16 unless the
  453.       receiver commands CRC-16.
  454.       
  455.       
  456.       4.  YMODEM Batch File Transmission
  457.       
  458.       The YMODEM Batch protocol is an extension to the XMODEM/CRC protocol that
  459.       allows 0 or more files to be transmitted with a single command.  (Zero
  460.       files may be sent if none of the requested files is accessible.) The
  461.       design approach of the YMODEM Batch protocol is to use the
  462.       normal routines for sending and receiving XMODEM packets in a
  463.       layered fashion similar to 
  464.       
  465.       
  466.       __________
  467.       
  468.        1. See "KMD/IMP Exceptions to YMODEM" below.
  469.       
  470.       
  471.       
  472.       
  473.       Chapter 4                                   XMODEM Protocol Enhancements
  474.       
  475.       
  476.       
  477.       
  478.       
  479.       
  480.       
  481.       X/YMODEM Protocol Reference         09-11-86                      8
  482.       
  483.       
  484.       
  485.          Figure 1.  1024 byte Packets
  486.       
  487.           SENDER                                  RECEIVER
  488.                                                   "s -k foo.bar"
  489.           "foo.bar open x.x minutes"
  490.                                                   C
  491.           STX 01 FE Data[1024] CRC CRC
  492.                                                   ACK
  493.           STX 02 FD Data[1024] CRC CRC
  494.                                                   ACK
  495.           STX 03 FC Data[1000] CPMEOF[24] CRC CRC
  496.                                                   ACK
  497.           EOT
  498.                                                   ACK
  499.       
  500.          Figure 2.  Mixed 1024 and 128 byte Packets
  501.       
  502.           SENDER                                  RECEIVER
  503.                                                   "s -k foo.bar"
  504.           "foo.bar open x.x minutes"
  505.                                                   C
  506.           STX 01 FE Data[1024] CRC CRC
  507.                                                   ACK
  508.           STX 02 FD Data[1024] CRC CRC
  509.                                                   ACK
  510.           SOH 03 FC Data[128] CRC CRC
  511.                                                   ACK
  512.           SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  513.                                                   ACK
  514.           EOT
  515.                                                   ACK
  516.       
  517.       packet switching methods.
  518.       
  519.       Why was it necessary to design a new batch protocol when one already
  520.       existed in MODEM7?[1] The batch file mode used by MODEM7 is unsuitable
  521.       because it does not permit full pathnames, file length, file date, or
  522.       other attribute information to be transmitted. Such a restrictive design,
  523.       hastily implemented with only CP/M in mind, would not have permitted
  524.       extensions to current areas of personal computing such as Unix, DOS, and
  525.       object oriented systems.  In addition, the MODEM7 batch file mode is
  526.       somewhat susceptible to transmission impairments.
  527.       
  528.       
  529.       
  530.       __________
  531.       
  532.        1. The MODEM7 batch protocol transmitted CP/M FCB bytes f1...f8 and
  533.           t1...t3 one character at a time.  The receiver echoed these bytes as
  534.           received, one at a time.
  535.       
  536.       
  537.       
  538.       
  539.       Chapter  4                             XMODEM Protocol Enhancements
  540.       
  541.       
  542.       
  543.       
  544.       
  545.       
  546.       
  547.       X/YMODEM Protocol Reference        09-11-86                        9
  548.       
  549.       
  550.       
  551.       As in the case of single a file transfer, the receiver initiates batch
  552.       file transmission by sending a "C" character (for CRC-16).
  553.       
  554.       The sender opens the first file and sends packet number 0 with the
  555.       following information.[2]
  556.       
  557.       Only the pathname (file name) part is required for batch transfers.
  558.       
  559.       To maintain upwards compatibility, all unused bytes in packet 0 must be
  560.       set to null.
  561.       
  562.       Pathname The pathname (conventionally, the file name) is sent as a null
  563.            terminated ASCII string.  This is the filename format used by the
  564.            handle oriented MSDOS(TM) functions and C library fopen functions.
  565.            An assembly language example follows:
  566.                       DB      'foo.bar',0
  567.            No spaces are included in the pathname.  Normally only the file name
  568.            stem (no directory prefix) is transmitted unless the sender has
  569.            selected YAM's f option to send the full pathname.  The source drive
  570.            (A:, B:, etc.) is never sent.
  571.       
  572.            Filename Considerations:
  573.       
  574.         + File names should be translated to lower case unless the sending
  575.          system supports upper/lower case file names. This is a
  576.          convenience for users of systems (such as Unix) which store
  577.          filenames in upper and lower case.
  578.       
  579.        + The receiver should accommodate file names in lower and upper
  580.          case.
  581.       
  582.        + When transmitting files between different operating systems,
  583.          file names must be acceptable to both the sender and receiving
  584.          operating systems.
  585.       
  586.            If directories are included, they are delimited by /; i.e.,
  587.            "subdir/foo" is acceptable, "subdir\foo" is not.
  588.       
  589.       Length The file length and each of the succeeding fields are optional.[3]
  590.            The length field is stored in the packet as a decimal
  591.            string counting the number of data bytes in the file.  The
  592.            file length does not include any CPMEOF (^Z) or other
  593.            garbage characters used to pad the last packet.
  594.       
  595.       
  596.       __________
  597.       
  598.        2. Only the data part of the packet is described here.
  599.       
  600.        3. Fields may not be skipped.
  601.       
  602.       
  603.       
  604.       
  605.       Chapter 4                               XMODEM Protocol Enhancements
  606.       
  607.       
  608.       
  609.       
  610.       
  611.       
  612.       
  613.       X/YMODEM Protocol Reference  09-11-86                             10
  614.       
  615.       
  616.       
  617.            If the file being transmitted is growing during transmission, the
  618.            length field should be set to at least the final expected file
  619.            length, or not sent.
  620.       
  621.            The receiver stores the specified number of characters, discarding
  622.            any padding added by the sender to fill up the last packet.
  623.       
  624.       Modification Date The mod date is optional, and the filename and length
  625.            may be sent without requiring the mod date to be sent.
  626.       
  627.            Iff the modification date is sent, a single space separates the
  628.            modification date from the file length.
  629.       
  630.            The mod date is sent as an octal number giving the time the contents
  631.            of the file were last changed, measured in seconds from Jan 1 1970
  632.            Universal Coordinated Time (GMT). A date of 0 implies the
  633.            modification date is unknown and should be left as the date the file
  634.            is received.
  635.       
  636.            This standard format was chosen to eliminate ambiguities
  637.            arising from transfers between different time zones.
  638.       
  639.            Two Microsoft blunders complicate the use of modification dates in
  640.            file transfers with MSDOS(TM) systems.  The first is the lack of
  641.            timezone standardization in MS-DOS.  A file's creation time can not
  642.            be known unless the timezone of the system that wrote the file[4] is
  643.            known.  Unix solved this problem (for planet Earth, anyway) by
  644.            stamping files with Universal Time (GMT). Microsoft would have to
  645.            include the timezone of origin in the directory entries, but does
  646.            not.  Professional-YAM gets around this problem by using the z
  647.            parameter which is set to the number of minutes local time lags GMT.
  648.            For files known to originate from a different timezone, the -zT
  649.            option may be used to specify T as the timezone for an individual
  650.            file transfer.
  651.       
  652.            The second problem is the lack of a separate file creation date in
  653.            DOS.  Since some backup schemes used with DOS rely on the file
  654.            creation date to select files to be copied to the archive, back-
  655.            dating the file modification date could interfere with the safety of
  656.            the transferred files.  For this reason, Pro-YAM does not modify the
  657.            date of received files with the header information unless the d
  658.            numeric parameter is non zero.
  659.       
  660.       
  661.       
  662.       
  663.       
  664.       __________
  665.       
  666.        4. Not necessarily that of the transmitting system!
  667.       
  668.       
  669.       
  670.       
  671.       Chapter   4                             XMODEM Protocol Enhancements
  672.       
  673.       
  674.       
  675.       
  676.       
  677.       
  678.       
  679.       X/YMODEM Protocol Reference        09-11-86                       11
  680.       
  681.       
  682.       
  683.       Mode Iff the file mode is sent, a single space separates the file mode
  684.            from the modification date.  The file mode is stored as an octal
  685.            string.  Unless the file originated from a Unix system, the
  686.            file mode is set to 0.  rb(1) checks the file mode for the
  687.            0x8000 bit which indicates a Unix type regular file.  Files
  688.            with the 0x8000 bit set are assumed to have been sent from
  689.            another Unix (or similar) system which uses the same file
  690.            conventions.  Such files are not translated in any way.
  691.       
  692.       
  693.       Serial Number Iff the serial number is sent, a single space separates the
  694.            serial number from the file mode. The serial number of the
  695.            transmitting program is stored as an octal string.
  696.            Programs which do not have a serial number should omit this
  697.            field, or set it to 0.  The receiver's use of this field is
  698.            optional. 
  699.       
  700.       
  701.       Other Fields YMODEM was designed to allow additional header fields to be
  702.            added as above without creating compatibility problems with older
  703.            YMODEM programs.  Please contact Omen Technology if other fields are
  704.            needed for special application requirements.
  705.       
  706.       The rest of the packet is set to nulls.  This is essential to preserve
  707.       upward compatibility.[5]
  708.       
  709.       If the filename packet is received with a CRC or other error, a
  710.       restrnsmission is requested.  After the filename packet has been
  711.       received, it is ACK'ed if the write open is successful.  If the
  712.       file cannot be opened for writing, the receiver cancels the
  713.       transfer with CAN characters as described above.
  714.       
  715.       The receiver then initiates transfer of the file contents
  716.       according to the standard XMODEM/CRC protocol.
  717.       
  718.       After the file contents have been transmitted, the receiver
  719.       again asks for the next pathname.  Transmission of a null
  720.       pathname terminates batch file transmission.  Note that
  721.       transmission of no files is not necessarily an error. This is
  722.       possible if none of the files requested of the sender could be
  723.       opened for reading. 
  724.       
  725.       In batch transmission, the receiver automatically requests CRC-16.
  726.       
  727.       The Unix programs sz(1) and rz(1) included in the source code file
  728.       
  729.       
  730.       __________
  731.       
  732.        5. If, perchance, this information extends beyond 128 bytes (possible
  733.           with Unix 4.2 BSD extended file names), the packet should be
  734.           sent as a 1k packet as described above.
  735.       
  736.       
  737.       
  738.       
  739.       Chapter   4                             XMODEM Protocol Enhancements
  740.       
  741.       
  742.       
  743.       
  744.       
  745.       
  746.       
  747.       X/YMODEM Protocol Reference        09-11-86                       12
  748.       
  749.       
  750.       
  751.       RZSZ[12].SHQ (rzsz1.sh, rzsz2.sh) should answer other questions about
  752.       YMODEM batch protocol.
  753.       
  754.          Figure 3.  YMODEM Batch Transmission Session
  755.       
  756.           SENDER                                  RECEIVER
  757.                                                   "sb foo.*<CR>"
  758.           "sending in batch mode etc."
  759.                                                   C (command:rb)
  760.           SOH 00 FF foo.c NUL[123] CRC CRC
  761.                                                   ACK
  762.                                                   C
  763.           SOH 01 FE Data[128] CRC CRC
  764.                                                   ACK
  765.           STX 02 FD Data[1024] CRC CRC
  766.                                                   ACK
  767.           SOH 03 FC Data[128] CRC CRC
  768.                                                   ACK
  769.           SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  770.                                                   ACK
  771.           EOT
  772.                                                   NAK
  773.           EOT
  774.                                                   ACK
  775.                                                   C
  776.           SOH 00 FF NUL[128] CRC CRC
  777.                                                   ACK
  778.       
  779.              Figure 4.  YMODEM Filename packet transmitted by sz
  780.       
  781.              -rw-r--r--  6347 Jun 17 1984 20:34 bbcsched.txt
  782.       
  783.              00 0100FF62 62637363 6865642E 74787400     |...bbcsched.txt.|
  784.              10 36333437 20333331 34373432 35313320     |6347 3314742513 |
  785.              20 31303036 34340000 00000000 00000000     |100644..........|
  786.              30 00000000 00000000 00000000 00000000
  787.              80 000000CA 56
  788.       
  789.       
  790.       
  791.       
  792.       
  793.       
  794.       
  795.       
  796.       
  797.       
  798.       
  799.       
  800.       
  801.       
  802.       
  803.       
  804.       
  805.       Chapter   4                             XMODEM Protocol Enhancements
  806.       
  807.       
  808.       
  809.       
  810.       
  811.       
  812.       
  813.       X/YMODEM Protocol Reference        09-11-86                       13
  814.       
  815.       
  816.       
  817.             Figure 5.    YMODEM Header Information used by various programs
  818.       
  819.       _____________________________________________________________________
  820.       | Program   | Batch | Length | Date | Mode | S/N | 1k-Blk | g-Option |
  821.       |___________|_______|________|______|______|_____|________|__________|
  822.       |Unix rz/sz | yes   | yes    | yes  | yes  | no  | yes    | sb only  |
  823.       |___________|_______|________|______|______|_____|________|__________|
  824.       |VMS rb/sb  | yes   | yes    | no   | no   | no  | yes    | no       |
  825.       |___________|_______|________|______|______|_____|________|__________|
  826.       |Pro-YAM    | yes   | yes    | yes  | no   | yes | yes    | yes      |
  827.       |___________|_______|________|______|______|_____|________|__________|
  828.       |CP/M YAM   | yes   | no     | no   | no   | no  | yes    | no       |
  829.       |___________|_______|________|______|______|_____|________|__________|
  830.       |KMD/IMP    | yes   | ?      | no   | no   | no  | yes    | no       |
  831.       |___________|_______|________|______|______|_____|________|__________|
  832.       
  833.       4.1  KMD/IMP Exceptions to YMODEM
  834.       
  835.       KMD and IMP character sequence emitted by the receiver (CK) to
  836.       automatically trigger the use of 1024 byte packets as an alternative to
  837.       specifying this option on this command line.  Although this two character
  838.       sequence works well on single process micros in direct communication,
  839.       timesharing systems and packet switched networks can separate the
  840.       successive characters by several seconds, rendering this method
  841.       unreliable.
  842.       
  843.       Sending programs may detect the CK sequence if the operating enviornment
  844.       does not preclude reliable implementation.
  845.       
  846.       Receiving programs should retain the option of sending the
  847.       standard YMODEM C (not CK) trigger with the standard 10 second
  848.       timeout to insure compatibility with newer forms of
  849.       telecommunications technology. 
  850.       
  851.       
  852.       
  853.       5.  YMODEM-g File Transmission
  854.       
  855.       Developing technology is providing phone line data transmission at ever
  856.       higher speeds using very specialized techniques.  These high
  857.       speed modems, as well as session protocols such as X.PC, provide
  858.       high speed, error free communications at the expense of
  859.       considerably increased delay time. 
  860.       
  861.       This delay time is moderate compared to human interactions, but it
  862.       cripples the throughput of most error correcting protocols.
  863.       
  864.       The g option to YMODEM has proven effective under these circumstances.
  865.       The g option is driven by the receiver, which initiates the
  866.       batch transfer by transmitting a G instead of C.  When the
  867.       sender recognizes the G, it bypasses the usual wait for an ACK
  868.       to each transmitted packet, sending succeeding packets at full
  869.       speed, subject to XOFF/XON or other flow control exerted by the medium.
  870.       
  871.       
  872.       
  873.       Chapter   5                             XMODEM Protocol Enhancements
  874.       
  875.       
  876.       
  877.       
  878.       
  879.       
  880.       
  881.       X/YMODEM Protocol Reference        09-11-86                       14
  882.       
  883.       
  884.       
  885.       The sender expects an inital G to initiate the transmission of a
  886.       particular file, and also expects an ACK on the EOT sent at the end of
  887.       each file.  This synchronization allows the receiver time to open and
  888.       close files as necessary.
  889.       
  890.       If an error is detected in a YMODEM-g transfer, the receiver aborts the
  891.       transfer with the multiple CAN abort sequence. The ZMODEM protocol should
  892.       be used in applications that require both streaming throughput and error
  893.       recovery.
  894.       
  895.              Figure 6.  YMODEM-g Transmission Session
  896.       
  897.              SENDER                                      RECEIVER
  898.                                                  "sb foo.*<CR>"
  899.              "sending   in batch mode etc..."
  900.                                                  G (command:rb -g)
  901.              SOH 00 FF foo.c NUL[123]   CRC CRC
  902.                                                  G
  903.              SOH 01 FE Data[128] CRC CRC
  904.              STX 02 FD Data[1024] CRC   CRC
  905.              SOH 03 FC Data[128] CRC CRC
  906.              SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  907.              EOT
  908.                                                  ACK
  909.                                                  G
  910.              SOH 00 FF NUL[128] CRC CRC
  911.       
  912.       
  913.       6.  XMODEM PROTOCOL OVERVIEW
  914.       
  915.       8/9/82 by Ward Christensen.
  916.       
  917.       I will maintain a master copy of this. Please pass on changes or
  918.       suggestions via CBBS/Chicago at (312) 545-8086, CBBS/CPMUG (312) 849-1132
  919.       or by voice at (312) 849-6279.
  920.       
  921.       6.1  Definitions
  922.       
  923.         <soh>   01H
  924.         <eot>   04H
  925.         <ack>   06H
  926.         <nak>   15H
  927.         <can>   18H
  928.         <C>     43H
  929.       
  930.       
  931.       
  932.       
  933.       
  934.       
  935.       
  936.       
  937.       
  938.       
  939.       Chapter   6                                 Xmodem Protocol Overview
  940.       
  941.       
  942.       
  943.       
  944.       
  945.       
  946.       
  947.       X/YMODEM Protocol Reference        09-11-86                       15
  948.       
  949.       
  950.       
  951.       6.2  Transmission Medium Level Protocol
  952.       
  953.       Asynchronous, 8 data bits, no parity, one stop bit.
  954.       
  955.       The protocol imposes no restrictions on the contents of the data being
  956.       transmitted.  No control characters are looked for in the 128-byte data
  957.       messages.  Absolutely any kind of data may be sent - binary, ASCII, etc.
  958.       The protocol has not formally been adopted to a 7-bit environment for the
  959.       transmission of ASCII-only (or unpacked-hex) data , although it could be
  960.       simply by having both ends agree to AND the protocol-dependent data with
  961.       7F hex before validating it.  I specifically am referring to the
  962.       checksum, and the block numbers and their ones- complement.
  963.       
  964.       Those wishing to maintain compatibility of the CP/M file structure, i.e.
  965.       to allow modemming ASCII files to or from CP/M systems should follow this
  966.       data format:
  967.       
  968.          + ASCII tabs used (09H); tabs set every 8.
  969.       
  970.          + Lines terminated by CR/LF (0DH 0AH)
  971.       
  972.          + End-of-file indicated by ^Z, 1AH. (one or more)
  973.       
  974.          + Data is variable length, i.e. should be considered a continuous
  975.            stream of data bytes, broken into 128-byte chunks purely for the
  976.            purpose of transmission.
  977.       
  978.          + A CP/M "peculiarity": If the data ends exactly on a 128-byte
  979.            boundary, i.e. CR in 127, and LF in 128, a subsequent sector
  980.            containing the ^Z EOF character(s) is optional, but is preferred.
  981.            Some utilities or user programs still do not handle EOF without ^Zs.
  982.       
  983.          + The last block sent is no different from others, i.e.  there is no
  984.            "short block".
  985.               Figure 7.  XMODEM Message Block Level Protocol
  986.       
  987.       Each block of the transfer looks like:
  988.             <SOH><blk #><255-blk #><--128 data bytes--><cksum>
  989.       in which:
  990.       <SOH>           = 01 hex
  991.       <blk #>         = binary number, starts at 01 increments by 1, and
  992.                 wraps 0FFH to 00H (not to 01)
  993.       <255-blk #>   =   blk # after going thru 8080 "CMA" instr, i.e.
  994.                 each bit complemented in the 8-bit block number.
  995.                 Formally, this is the "ones complement".
  996.       <cksum>       = the sum of the data bytes only.  Toss any carry.
  997.       
  998.       
  999.       
  1000.       
  1001.       
  1002.       
  1003.       
  1004.       
  1005.       Chapter   6                                 Xmodem Protocol Overview
  1006.       
  1007.       
  1008.       
  1009.       
  1010.       
  1011.       
  1012.       
  1013.       X/YMODEM Protocol Reference        09-11-86                       16
  1014.       
  1015.       
  1016.       
  1017.       6.3  File Level Protocol
  1018.       
  1019.       6.3.1  Common_to_Both_Sender_and_Receiver
  1020.       All errors are retried 10 times.  For versions running with an operator
  1021.       (i.e. NOT with XMODEM), a message is typed after 10 errors asking the
  1022.       operator whether to "retry or quit".
  1023.       
  1024.       Some versions of the protocol use <can>, ASCII ^X, to cancel
  1025.       transmission. This was never adopted as a standard, as having a
  1026.       single "abort" character makes the transmission susceptible to
  1027.       false termination due to an <ack> <nak> or <soh> being corrupted
  1028.       into a <can> and aborting transmission. 
  1029.       
  1030.       The protocol may be considered "receiver driven", that is, the
  1031.       sender need not automatically re-transmit, although it does in
  1032.       the current implementations.
  1033.       
  1034.       
  1035.       6.3.2  Receive_Program_Considerations
  1036.       The receiver has a 10-second timeout.  It sends a <nak> every time it
  1037.       times out.  The receiver's first timeout, which sends a <nak>,
  1038.       signals the transmitter to start.  Optionally, the receiver
  1039.       could send a <nak> immediately, in case the sender was ready.
  1040.       This would save the initial 10 second timeout.  However, the
  1041.       receiver MUST continue to timeout every 10 seconds in case the
  1042.       sender wasn't ready. 
  1043.       
  1044.       Once into a receiving a block, the receiver goes into a
  1045.       one-second timeout for each character and the checksum.  If the
  1046.       receiver wishes to <nak> a block for any reason (invalid header,
  1047.       timeout receiving data), it must wait for the line to clear.
  1048.       See "programming tips" for ideas.
  1049.       
  1050.       Synchronizing: If a valid block number is received, it will be: 1) the
  1051.       expected one, in which case everything is fine; or 2) a repeat of the
  1052.       previously received block.  This should be considered OK, and only
  1053.       indicates that the receivers <ack> got glitched, and the sender re-
  1054.       transmitted; 3) any other block number indicates a fatal loss of
  1055.       synchronization, such as the rare case of the sender getting a
  1056.       line-glitch that looked like an <ack>.  Abort the transmission,
  1057.       sending a <can> 
  1058.       
  1059.       
  1060.       6.3.3  Sending_program_considerations
  1061.       While waiting for transmission to begin, the sender has only a
  1062.       single very long timeout, say one minute.  In the current
  1063.       protocol, the sender has a 10 second timeout before retrying.  I
  1064.       suggest NOT doing this, and letting the protocol be completely
  1065.       receiver-driven.  This will be compatible with existing programs.
  1066.       
  1067.       When the sender has no more data, it sends an <eot>, and awaits an <ack>,
  1068.       resending the <eot> if it doesn't get one.  Again, the protocol could be
  1069.       receiver-driven, with the sender only having the high-level 1-minute
  1070.       timeout to abort.
  1071.       
  1072.       
  1073.       
  1074.       
  1075.       Chapter   6                                 Xmodem Protocol Overview
  1076.       
  1077.       
  1078.       
  1079.       
  1080.       
  1081.       
  1082.       
  1083.       X/YMODEM Protocol Reference        09-11-86                       17
  1084.       
  1085.       
  1086.       
  1087.       Here is a sample of the data flow, sending a 3-block message.
  1088.       It includes the two most common line hits - a garbaged block,
  1089.       and an <ack> reply getting garbaged.  <xx> represents the checksum byte.
  1090.       
  1091.              Figure 8.  Data flow including Error Recovery
  1092.       
  1093.       SENDER                            RECEIVER
  1094.                               times out after 10 seconds,
  1095.                               <---              <nak>
  1096.       <soh> 01 FE -data- <xx>         --->
  1097.                               <---              <ack>
  1098.       <soh> 02 FD -data- xx           --->       (data gets line hit)
  1099.                               <---              <nak>
  1100.       <soh> 02 FD -data- xx           --->
  1101.                               <---              <ack>
  1102.       <soh> 03 FC -data- xx           --->
  1103.       (ack gets garbaged)             <---              <ack>
  1104.       <soh> 03 FC -data- xx           --->              <ack>
  1105.       <eot>                           --->
  1106.                               <---       <anything except ack>
  1107.       <eot>                           --->
  1108.                               <---              <ack>
  1109.       (finished)
  1110.       
  1111.       6.4  Programming Tips
  1112.       
  1113.          + The character-receive subroutine should be called with a parameter
  1114.            specifying the number of seconds to wait. The receiver should first
  1115.            call it with a time of 10, then <nak> and try again, 10 times.
  1116.       
  1117.            After receiving the <soh>, the receiver should call the character
  1118.            receive subroutine with a 1-second timeout, for the remainder of the
  1119.            message and the <cksum>.  Since they are sent as a
  1120.            continuous stream, timing out of this implies a serious
  1121.            like glitch that caused, say, 127 characters to be seen
  1122.            instead of 128. 
  1123.       
  1124.          + When the receiver wishes to <nak>, it should call a "PURGE"
  1125.            subroutine, to wait for the line to clear.  Recall the sender tosses
  1126.            any characters in its UART buffer immediately upon
  1127.            completing sending a block, to ensure no glitches were mis- 
  1128.            interpreted. 
  1129.       
  1130.            The most common technique is for "PURGE" to call the character
  1131.            receive subroutine, specifying a 1-second timeout,[1] and looping
  1132.            back to PURGE until a timeout occurs.  The <nak> is then sent,
  1133.            ensuring the other end will see it.
  1134.       
  1135.       
  1136.       __________
  1137.       
  1138.        1. These times should be adjusted for use with timesharing systems.
  1139.       
  1140.       
  1141.       
  1142.       
  1143.       Chapter   6                                 Xmodem Protocol Overview
  1144.       
  1145.       
  1146.       
  1147.       
  1148.       
  1149.       
  1150.       
  1151.       X/YMODEM Protocol Reference        09-11-86                       18
  1152.       
  1153.       
  1154.       
  1155.          + You may wish to add code recommended by John Mahr to your character
  1156.            receive routine - to set an error flag if the UART shows framing
  1157.            error, or overrun.  This will help catch a few more glitches - the
  1158.            most common of which is a hit in the high bits of the byte in two
  1159.            consecutive bytes.  The <cksum> comes out OK since counting
  1160.            in 1-byte produces the same result of adding 80H + 80H as
  1161.            with adding 00H + 00H.
  1162.       
  1163.       
  1164.       
  1165.       7.  XMODEM/CRC Overview
  1166.       
  1167.       1/13/85 by John Byrns -- CRC option.
  1168.       
  1169.       Please pass on any reports of errors in this document or suggestions for
  1170.       improvement to me via Ward's/CBBS at (312) 849-1132, or by voice at (312)
  1171.       885-1105.
  1172.       
  1173.       The CRC used in the Modem Protocol is an alternate form of block check
  1174.       which provides more robust error detection than the original checksum.
  1175.       Andrew S. Tanenbaum says in his book, Computer Networks, that the CRC-
  1176.       CCITT used by the Modem Protocol will detect all single and double bit
  1177.       errors, all errors with an odd number of bits, all burst errors of length
  1178.       16 or less, 99.997% of 17-bit error bursts, and 99.998% of 18-bit and
  1179.       longer bursts.
  1180.       
  1181.       The changes to the Modem Protocol to replace the checksum with
  1182.       the CRC are straight forward. If that were all that we did we
  1183.       would not be able to communicate between a program using the old
  1184.       checksum protocol and one using the new CRC protocol. An initial
  1185.       handshake was added to solve this problem. The handshake allows
  1186.       a receiving program with CRC capability to determine whether the
  1187.       sending program supports the CRC option, and to switch it to CRC
  1188.       mode if it does. This handshake is designed so that it will work
  1189.       properly with programs which implement only the original
  1190.       protocol. A description of this handshake is presented in section 10. 
  1191.       
  1192.            Figure 9.  Message Block Level Protocol, CRC mode
  1193.       
  1194.       Each block of the transfer in CRC mode looks like:
  1195.            <SOH><blk #><255-blk #><--128 data   bytes--><CRC hi><CRC lo>
  1196.       in which:
  1197.       <SOH>          = 01 hex
  1198.       <blk #>        = binary number, starts at 01 increments by 1, and
  1199.                wraps 0FFH to 00H (not to 01)
  1200.       <255-blk #>  = ones complement of blk #.
  1201.       <CRC hi>     = byte containing the 8 hi   order coefficients of the CRC.
  1202.       <CRC lo>     = byte containing the 8 lo   order coefficients of the CRC.
  1203.       
  1204.       
  1205.       
  1206.       
  1207.       
  1208.       
  1209.       
  1210.       Chapter   7                                 Xmodem Protocol Overview
  1211.       
  1212.       
  1213.       
  1214.       
  1215.       
  1216.       
  1217.       
  1218.       X/YMODEM Protocol Reference        09-11-86                       19
  1219.       
  1220.       
  1221.       
  1222.       7.1  CRC Calculation
  1223.       
  1224.       7.1.1  Formal_Definition
  1225.       To calculate the 16 bit   CRC the message bits are considered to be the
  1226.       coefficients of a polynomial. This message polynomial is first multiplied
  1227.       by X^16 and then divided by the generator polynomial (X^16 + X^12 + X^5 +
  1228.       1) using modulo two arithmetic. The remainder left after the division is
  1229.       the desired CRC. Since a message block in the Modem Protocol is 128 bytes
  1230.       or 1024 bits, the message polynomial will be of order X^1023.
  1231.       The hi order bit of the first byte of the message block is the
  1232.       coefficient of X^1023 in the message polynomial.  The lo order
  1233.       bit of the last byte of the message block is the coefficient of
  1234.       X^0 in the message polynomial. 
  1235.       
  1236.           Figure 10.  Example of CRC Calculation written in C
  1237.       UPDCRC update routine from "rbsb.c".  Refer to the source code for these
  1238.       programs (contained in RZSZ1.SHQ and RZSZ2.SHQ) for usage.  A fast table
  1239.       driven macro is also included in this file.
  1240.       /* update CRC */
  1241.       unsigned short
  1242.       updcrc(c, crc)
  1243.       register c;
  1244.       register unsigned crc;
  1245.       {
  1246.         register count;
  1247.       
  1248.         for (count=8; --count>=0;) {
  1249.                 if (crc & 0x8000) {
  1250.                         crc <<= 1;
  1251.                         crc += (((c<<=1) & 0400)  !=  0);
  1252.                         crc ^= 0x1021;
  1253.                 }
  1254.                 else {
  1255.                         crc <<= 1;
  1256.                         crc += (((c<<=1) & 0400)  !=  0);
  1257.                 }
  1258.         }
  1259.         return crc;
  1260.       }
  1261.       
  1262.       7.2  CRC File Level Protocol Changes
  1263.       
  1264.       7.2.1  Common_to_Both_Sender_and_Receiver
  1265.       The only change to the File Level Protocol for the CRC option is the
  1266.       initial handshake which is used to determine if both the sending and the
  1267.       receiving programs support the CRC mode. All Modem Programs
  1268.       should support the checksum mode for compatibility with older
  1269.       versions.  A receiving program that wishes to receive in CRC
  1270.       mode implements the mode setting handshake by sending a <C> in
  1271.       place of the initial <nak>.  If the sending program supports CRC
  1272.       mode it will recognize the <C> and will set itself into CRC
  1273.       mode, and respond by sending the first block as if a <nak> had 
  1274.       been received. If the sending program does not support CRC mode it will
  1275.       
  1276.       
  1277.       
  1278.       Chapter   7                                 Xmodem Protocol Overview
  1279.       
  1280.       
  1281.       
  1282.       
  1283.       
  1284.       
  1285.       
  1286.       X/YMODEM Protocol Reference        09-11-86                       20
  1287.       
  1288.       
  1289.       
  1290.       not respond to the <C> at all. After the receiver has sent the
  1291.       <C> it will wait up to 3 seconds for the <soh> that starts the
  1292.       first block. If it receives a <soh> within 3 seconds it will
  1293.       assume the sender supports CRC mode and will proceed with the
  1294.       file exchange in CRC mode. If no <soh> is received within 3
  1295.       seconds the receiver will switch to checksum mode, send a <nak>,
  1296.       and proceed in checksum mode. If the receiver wishes to use 
  1297.       checksum mode it should send an initial <nak> and the sending program
  1298.       should respond to the <nak> as defined in the original Modem Protocol.
  1299.       After the mode has been set by the initial <C> or <nak> the protocol
  1300.       follows the original Modem Protocol and is identical whether the checksum
  1301.       or CRC is being used.
  1302.       
  1303.       
  1304.       7.2.2  Receive_Program_Considerations
  1305.       There are at least 4 things that can go wrong with the mode setting
  1306.       handshake.
  1307.       
  1308.         1.  the initial <C> can be garbled or lost.
  1309.       
  1310.         2.  the initial <soh> can be garbled.
  1311.       
  1312.         3.  the initial <C> can be changed to a <nak>.
  1313.       
  1314.         4.  the initial <nak> from a receiver which wants to receive
  1315.             in checksum can be changed to a <C>.
  1316.       
  1317.       The first problem can be solved if the receiver sends a second <C> after
  1318.       it times out the first time. This process can be repeated several times.
  1319.       It must not be repeated too many times before sending a <nak> and
  1320.       switching to checksum mode or a sending program without CRC support may
  1321.       time out and abort. Repeating the <C> will also fix the second problem if
  1322.       the sending program cooperates by responding as if a <nak> were received
  1323.       instead of ignoring the extra <C>.
  1324.       
  1325.       It is possible to fix problems 3 and 4 but probably not worth the trouble
  1326.       since they will occur very infrequently. They could be fixed by switching
  1327.       modes in either the sending or the receiving program after a large number
  1328.       of successive <nak>s. This solution would risk other problems however.
  1329.       
  1330.       
  1331.       7.2.3  Sending_Program_Considerations
  1332.       The sending program should start in the checksum mode. This will insure
  1333.       compatibility with checksum only receiving programs. Anytime a <C> is
  1334.       received before the first <nak> or <ack> the sending program should set
  1335.       itself into CRC mode and respond as if a <nak> were received. The sender
  1336.       should respond to additional <C>s as if they were <nak>s until the first
  1337.       <ack> is received. This will assist the receiving program in determining
  1338.       the correct mode when the <soh> is lost or garbled. After the first <ack>
  1339.       is received the sending program should ignore <C>s.
  1340.       
  1341.       
  1342.       
  1343.       
  1344.       
  1345.       Chapter 7                                   Xmodem Protocol Overview
  1346.       
  1347.       
  1348.       
  1349.       
  1350.       
  1351.       
  1352.       
  1353.       X/YMODEM Protocol Reference        09-11-86                       21
  1354.       
  1355.       
  1356.       
  1357.       7.3  Data Flow Examples with CRC Option
  1358.       
  1359.       Here is a data flow example for the case where the receiver requests
  1360.       transmission in the CRC mode but the sender does not support the CRC
  1361.       option. This example also includes various transmission errors.  <xx>
  1362.       represents the checksum byte.
  1363.       
  1364.             Figure 11.  Data Flow: Receiver has CRC Option, Sender Doesn't
  1365.       
  1366.       SENDER                                          RECEIVER
  1367.                         <---                <C>
  1368.                                 times out after 3 seconds,
  1369.                         <---                <C>
  1370.                                 times out after 3 seconds,
  1371.                         <---                <C>
  1372.                                 times out after 3 seconds,
  1373.                         <---                <C>
  1374.                                 times out after 3 seconds,
  1375.                         <---                <nak>
  1376.       <soh> 01 FE -data- <xx>   --->
  1377.                         <---                <ack>
  1378.       <soh> 02 FD -data- <xx>   --->        (data gets line hit)
  1379.                         <---                <nak>
  1380.       <soh> 02 FD -data- <xx>   --->
  1381.                         <---                <ack>
  1382.       <soh> 03 FC -data- <xx>   --->
  1383.          (ack   gets garbaged)  <---                <ack>
  1384.                                 times out after 10 seconds,
  1385.                         <---                <nak>
  1386.       <soh> 03 FC -data- <xx>   --->
  1387.                         <---                <ack>
  1388.       <eot>                     --->
  1389.                         <---                <ack>
  1390.       
  1391.       Here is a data flow example for the case where the receiver requests
  1392.       transmission in the CRC mode and the sender supports the CRC
  1393.       option.  This example also includes various transmission errors.
  1394.       <xxxx> represents the  2 CRC bytes.
  1395.       
  1396.       
  1397.       
  1398.       
  1399.       
  1400.       
  1401.       
  1402.       
  1403.       
  1404.       
  1405.       
  1406.       
  1407.       
  1408.       
  1409.       
  1410.       
  1411.       Chapter 7                                   Xmodem Protocol Overview
  1412.       
  1413.       
  1414.       
  1415.       
  1416.       
  1417.       
  1418.       
  1419.       X/YMODEM Protocol Reference        09-11-86                       22
  1420.       
  1421.       
  1422.       
  1423.           Figure 12.  Receiver and Sender Both have CRC Option
  1424.       
  1425.       SENDER                                         RECEIVER
  1426.                           <---                 <C>
  1427.       <soh> 01 FE -data- <xxxx> --->
  1428.                           <---                 <ack>
  1429.       <soh> 02 FD -data- <xxxx> --->           (data gets line hit)
  1430.                           <---                 <nak>
  1431.       <soh> 02 FD -data- <xxxx> --->
  1432.                           <---                 <ack>
  1433.       <soh> 03 FC -data- <xxxx> --->
  1434.       (ack gets garbaged)         <---                 <ack>
  1435.                                      times out after 10 seconds,
  1436.                           <---                 <nak>
  1437.       <soh> 03 FC -data- <xxxx> --->
  1438.                           <---                 <ack>
  1439.       <eot>                       --->
  1440.                           <---                 <ack>
  1441.       
  1442.       
  1443.       8.  MORE INFORMATION
  1444.       
  1445.       More information may be obtained by calling Telegodzilla at 503-621-3746.
  1446.       Hit RETURNs for baud rate detection.Speed detection is automatic for 300,
  1447.       1200, and 2400 bps.
  1448.       
  1449.       A version this file with boldface, underlining, and superscripts for
  1450.       printing on Epson or Gemini printers is available on Telegodzilla as
  1451.       "YMODEME.DOC" or "YMODEME.DQC".
  1452.       
  1453.       UUCP sites can obtain this file   with
  1454.              uucp omen!/usr/spool/uucppublic/ymodem.doc /tmp
  1455.       A continually updated list of available   files is stored in
  1456.       /usr/spool/uucppublic/FILES.
  1457.       
  1458.       The following L.sys line calls Telegodzilla (Pro-YAM in host operation).
  1459.       Telegodzilla waits for carriage returns to determine the incoming speed.
  1460.       If none is detected, 1200 bps is assumed and a greeting is displayed.
  1461.       
  1462.       In response to "Name Please:" uucico gives the Pro-YAM "link"
  1463.       command as a user name.  The password (Giznoid) controls access
  1464.       to the Xenix system connected to the IBM PC's other serial port.
  1465.       Communications between Pro-YAM and Xenix use 9600 bps; YAM
  1466.       converts this to the caller's speed. 
  1467.       
  1468.       Finally, the calling uucico logs in as uucp.
  1469.       
  1470.       omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
  1471.       
  1472.       Contact omen!caf if you wish the troff source files.
  1473.       
  1474.       
  1475.       
  1476.       
  1477.       
  1478.       Chapter   8                                 Xmodem Protocol Overview
  1479.       
  1480.       
  1481.       
  1482.       
  1483.       
  1484.       
  1485.       
  1486.       X/YMODEM Protocol Reference        09-11-86                       23
  1487.       
  1488.       
  1489.       
  1490.       9.  Document Revisions
  1491.       
  1492.       The September 11 1986 edition clarifies nomenclature and some minor
  1493.       points.  The April 15 1986 edition clarifies some points concerning CRC
  1494.       calculations and spaces in the header.
  1495.       
  1496.       
  1497.       10.  YMODEM Programs
  1498.       
  1499.       A demonstration version of Professional-YAM is available as ZMODEM.ARC
  1500.       This may be used to test YMODEM amd ZMODEM implementations.
  1501.       
  1502.       Unix programs supporting the YMODEM protocol are available on
  1503.       Telegodzilla as RZSZ1.SHQ and RZSZ2.SHQ (SQueezed shell archives).
  1504.       Most Unix like systems are supported, including V7, Xenix, Sys III,
  1505.       4.2 BSD, SYS V, Idris, Coherent, and Regulus.
  1506.       
  1507.       A version for VAX-VMS is available in VRBSB.SHQ.
  1508.       
  1509.       Irv Hoff has added YMODEM 1k packets and basic YMODEM batch transfers to
  1510.       the KMD and IMP series programs, which replace the XMODEM and
  1511.       MODEM7/MDM7xx series respectively.  Overlays are available for a wide
  1512.       variety of CP/M systems.
  1513.       
  1514.       Questions about YMODEM, the Professional-YAM communications program, and
  1515.       requests for evaluation copies may be directed to:
  1516.            Chuck Forsberg
  1517.            Omen Technology Inc
  1518.            17505-V Sauvie Island Road
  1519.            Portland Oregon 97231
  1520.            Voice: 503-621-3406
  1521.            Modem: 503-621-3746 Speed: 2400,1200,300
  1522.            Usenet: ...!tektronix!reed!omen!caf
  1523.            Compuserve: 70007,2304
  1524.            Source: TCE022
  1525.       
  1526.       
  1527.       
  1528.       
  1529.       
  1530.       
  1531.       
  1532.       
  1533.       
  1534.       
  1535.       
  1536.       
  1537.       
  1538.       
  1539.       
  1540.       
  1541.       
  1542.       
  1543.       
  1544.       Chapter 10                                  Xmodem Protocol Overview
  1545.       
  1546.       
  1547.       
  1548.       
  1549.       
  1550.       
  1551.       
  1552.       
  1553.       
  1554.       
  1555.       
  1556.                                  CONTENTS
  1557.       
  1558.       
  1559.        1.  ROSETTA STONE....................................................  2
  1560.       
  1561.        2.  YET ANOTHER PROTOCOL?............................................  2
  1562.            2.1  Some Messages from the Pioneer..............................  4
  1563.       
  1564.        3.  XMODEM PROTOCOL ENHANCEMENTS.....................................  5
  1565.            3.1  Graceful Abort..............................................  6
  1566.            3.2  CRC-16 Option...............................................  6
  1567.            3.3  XMODEM-1k 1024 Byte Packet..................................  7
  1568.       
  1569.        4.  YMODEM Batch File Transmission...................................  7
  1570.            4.1  KMD/IMP Exceptions to YMODEM................................ 13
  1571.       
  1572.        5.  YMODEM-g File Transmission....................................... 13
  1573.       
  1574.        6.  XMODEM PROTOCOL OVERVIEW......................................... 14
  1575.            6.1  Definitions................................................. 14
  1576.            6.2  Transmission Medium Level Protocol.......................... 15
  1577.            6.3  File Level Protocol......................................... 16
  1578.            6.4  Programming Tips............................................ 17
  1579.       
  1580.        7.  XMODEM/CRC Overview.............................................. 18
  1581.            7.1  CRC Calculation............................................. 19
  1582.            7.2  CRC File Level Protocol Changes............................. 19
  1583.            7.3  Data Flow Examples with CRC Option.......................... 21
  1584.       
  1585.        8.  MORE INFORMATION................................................. 22
  1586.       
  1587.        9.  Document Revisions............................................... 23
  1588.       
  1589.       10.  YMODEM Programs.................................................. 23
  1590.       
  1591.       
  1592.       
  1593.       
  1594.       
  1595.       
  1596.       
  1597.       
  1598.       
  1599.       
  1600.       
  1601.       
  1602.       
  1603.       
  1604.       
  1605.       
  1606.       
  1607.       
  1608.       
  1609.       
  1610.                                    - i -
  1611.       
  1612.       
  1613.       
  1614.       
  1615.       
  1616.       
  1617.       
  1618.       
  1619.       
  1620.       
  1621.       
  1622.       
  1623.       
  1624.       
  1625.                              LIST OF FIGURES
  1626.       
  1627.       
  1628.        Figure 1.  1024 byte Packets.........................................  7
  1629.       
  1630.        Figure 2.  Mixed 1024 and 128 byte Packets...........................  7
  1631.       
  1632.        Figure 3.  YMODEM Batch Transmission Session......................... 12
  1633.       
  1634.        Figure 4.  YMODEM Filename packet transmitted by sz.................. 12
  1635.       
  1636.        Figure 5.  YMODEM Header Information used by various programs........ 13
  1637.       
  1638.        Figure 6.  YMODEM-g Transmission Session............................. 14
  1639.       
  1640.        Figure 7.  XMODEM Message Block Level Protocol....................... 15
  1641.       
  1642.        Figure 8.  Data flow including Error Recovery........................ 17
  1643.       
  1644.        Figure 9.  Message Block Level Protocol, CRC mode.................... 18
  1645.       
  1646.       Figure 10.  Example of CRC Calculation written in C................... 19
  1647.       
  1648.       Figure 11.  Data Flow: Receiver has CRC Option, Sender Doesn't........ 21
  1649.       
  1650.       Figure 12.  Receiver and Sender Both have CRC Option.................. 22
  1651.       
  1652.       
  1653.       
  1654.       
  1655.       
  1656.       
  1657.       
  1658.       
  1659.       
  1660.       
  1661.       
  1662.       
  1663.       
  1664.       
  1665.       
  1666.       
  1667.       
  1668.       
  1669.       
  1670.       
  1671.       
  1672.       
  1673.       
  1674.       
  1675.       
  1676.                                   - ii -
  1677.       
  1678.       
  1679.       
  1680.       
  1681.